<template>
  <div class="tab-control">
    <!-- 这里不用插槽的原因是 这个控制页面是固定了数量 固定了功能的 所以不需要插槽 -->
    <div v-for="(item,index) in titles" :key="index" class="Control-item"
    :class="{active:index==currentindex}" @click="ChangeColor(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      },
    },
  },data(){
    return {
      currentindex:0
    }
  },
  methods:{
    ChangeColor(index){
       this.currentindex=index;
       this.$emit("tabClick",index);
    }
  }
};
</script>

<style scoped>
.tab-control{
  display: flex;
  text-align: center;
  font-size: 15px;
  /* position: sticky; */
  top: 44px;
  background-color: #fff;
  z-index: 9;
}
.Control-item{
   flex: 1;
   height: 40px;
   line-height: 40px;
}
.active{
 color:var(--color-high-text);
}
.active span{
  border-bottom:3px solid var(--color-tint) ;
  padding: 5px;
 
}
</style>